package com.zjlp.seproject.service.impl;

import com.zjlp.seproject.mapper.ProfileMapper;
import com.zjlp.seproject.mapper.SubjectMapper;
import com.zjlp.seproject.mapper.UserMapper;
import com.zjlp.seproject.pojo.Comment;
import com.zjlp.seproject.pojo.Subject;
import com.zjlp.seproject.pojo.User;
import com.zjlp.seproject.service.ProfileService;
import com.zjlp.seproject.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private ProfileMapper profileMapper;

    public List<User> selectAll(){
        return userMapper.selectAll();
    }

    public int deleteByPrimaryKey(Integer id){
        return userMapper.deleteByPrimaryKey(id);
    }

    public int insert(User record){
        return userMapper.insert(record);
    }

    public User selectByPrimaryKey(Integer id){
        return userMapper.selectByPrimaryKey(id);
    }

    public int updateByPrimaryKey(User record){
        return userMapper.updateByPrimaryKey(record);
    }

    @Override
    public User login(User user) {
        return userMapper.login(user);
    }

    @Override
    public Integer register(User user) {
        profileMapper.init(user.getId());
        return userMapper.register(user);
    }

    @Override
    public Integer avatar(User user) {
        return userMapper.avatar(user);
    }

    @Override
    public User admin(Integer id) {
        return userMapper.admin(id);
    }
}
